// 指令-容器大小改变时触发绑定函数
export default {
  bind(el, binding) {
    let width = ''
    let height = ''
    const getSize = () => {
      const style = document.defaultView.getComputedStyle(el)
      if (width !== style.width || height !== style.height) {
        binding.value({
          width,
          height
        })
      }
      width = style.width
      height = style.height
    }
    // eslint-disable-next-line no-underscore-dangle
    el.__vueReize__ = setInterval(getSize, 200)
  },
  unbind(el) {
    // eslint-disable-next-line no-underscore-dangle
    clearInterval(el.__vueReize__)
  }
}
